package model
import (
	_ "github.com/mattn/go-sqlite3"
	"github.com/go-xorm/core"
	"github.com/go-xorm/xorm"
	"time"
	"fmt"
)

type UserJob struct{
	Id int64
	JobName string
	Status bool
	Desc string
	JobDate time.Time
}
func (x UserJob)Save()int64{
	var affected int64
	var err error
	if x.Id>0 {
		affected, err = engine.Update(x)
	}else{
		affected, err = engine.Insert(x)
	}
	if err!=nil{
		fmt.Println("xorm error:",err)
	}
	return affected
}




var engine *xorm.Engine

func init() {
	var err error
	engine, err = xorm.NewEngine("sqlite3", "./test.db")
	if err != nil {
		fmt.Println("xorm error:", err)
	}

	engine.ShowSQL = true
	engine.SetMapper(core.SameMapper{})
	err = engine.Sync(new(UserJob))
}

